<?php
$cs=Yii::app()->getClientScript();
$cs->registerCoreScript('jquery');
$cs->registerScriptFile(SystemAsset::toUrl('jquery.charcounter.js'));

$titleId=CHtml::activeId($recipe,'title');
$titleMaxLen=Recipe::TITLE_MAX_LEN;
$cs->registerScript("setTitleCharCounter","
    $('#$titleId').charCounter($titleMaxLen);
");

$descriptionId=CHtml::activeId($recipe,'description');
$descriptionMaxLen=Recipe::DESCRIPTION_MAX_LEN;
$cs->registerScript("setDescCharCounter","
    $('#$descriptionId').charCounter($descriptionMaxLen);
");

?>
<div>
  <h2>创建新食谱</h2>
  <?php echo CHtml::beginForm('','post',array('enctype'=>'multipart/form-data')); ?>
  <?php echo CHtml::errorSummary($recipe); ?>

  <div>
    <h3 class="title">
      <?php echo CHtml::activeLabel($recipe,'title'); ?>
    </h3>
    <?php echo CHtml::activeTextField($recipe,'title',array('size'=>40)); ?>
  </div>

  <div>
    <h3 class="description">
        <?php echo CHtml::activeLabel($recipe,'description'); ?>
    </h3>
    <?php echo CHtml::activeTextArea($recipe,'description',array('style'=>'width: 400px; height: 80px;')); ?>
  </div>

  <div>
    <h3 class="image">
        <?php echo CHtml::activeLabel($recipe,'image'); ?>
    </h3>
    <?php echo CHtml::activeFileField($recipe,'image',array('size'=>40)); ?>
  </div>

  <div style="text-align: center; margin-top: 20px; font-size: 21px;" class="submit">
    <?php echo CHtml::submitButton('创建'); ?>
  </div>

  <?php echo CHtml::endForm(); ?>
</div>